From: Owen W. Taylor Date: Sat, 30 Oct 2010 21:28:36 +0000 (-0400) Subject: Fix cursor image tracking on 64-bit systems X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~9575 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=909ec7a7090efb5b371ffdf5211ca67aab9fc5b3;p=gnome-shell.git Fix cursor image tracking on 64-bit systems Like all X API, XFixesGetCursorImage returns arrays of 32-bit quantities as arrays of long; on 64-bit systems we need to convert to an array of 32-bit words before creating a texture from the result. https://bugzilla.gnome.org/show_bug.cgi?id=633591 --- diff --git a/src/shell-xfixes-cursor.c b/src/shell-xfixes-cursor.c index baf677c5c..14d2b59c4 100644 --- a/src/shell-xfixes-cursor.c +++ b/src/shell-xfixes-cursor.c @@ -195,11 +195,40 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor) { XFixesCursorImage *cursor_image; CoglHandle sprite = COGL_INVALID_HANDLE; + guint8 *cursor_data; + gboolean free_cursor_data; if (!xfixes_cursor->have_xfixes) return; cursor_image = XFixesGetCursorImage (clutter_x11_get_default_display ()); + + /* Like all X APIs, XFixesGetCursorImage() returns arrays of 32-bit + * quantities as arrays of long; we need to convert on 64 bit */ + if (sizeof(long) == 4) + { + cursor_data = (guint8 *)cursor_image->pixels; + free_cursor_data = FALSE; + } + else + { + int i, j; + guint32 *cursor_words; + gulong *p; + guint32 *q; + + cursor_words = g_new (guint32, cursor_image->width * cursor_image->height); + cursor_data = (guint8 *)cursor_words; + + p = cursor_image->pixels; + q = cursor_words; + for (j = 0; j < cursor_image->height; j++) + for (i = 0; i < cursor_image->width; i++) + *(q++) = *(p++); + + free_cursor_data = TRUE; + } + sprite = cogl_texture_new_from_data (cursor_image->width, cursor_image->height, COGL_TEXTURE_NONE, @@ -210,7 +239,11 @@ xfixes_cursor_reset_image (ShellXFixesCursor *xfixes_cursor) #endif COGL_PIXEL_FORMAT_ANY, cursor_image->width * 4, /* stride */ - (const guint8 *) cursor_image->pixels); + cursor_data); + + if (free_cursor_data) + g_free (cursor_data); + if (sprite != COGL_INVALID_HANDLE) { if (xfixes_cursor->cursor_sprite != NULL)